#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int N = 300010;
typedef pair<int, int> pii;
int n, m;
int a[N], s[N];

vector<int> q;
vector<pii> add, query;

int f(int x) {
    int l = 0, r = q.size() - 1;
    while (l < r) {
        int m = l + r >> 1;
        if (q[m] >= x) r = m;
        else l = m + 1;
    }
    return r + 1;
}

//此处使用离散化 + 前缀和处理
int main() {
    cin >> n >> m;
    while(n--)) {
        int x, c;
        cin >> x >> c;
        add.push_back({x, c});
        q.push_back(x);
    }
    while(m--)) {
        int l, r;
        cin >> l >> r;
        query.push_back({l, r});
        q.push_back(l);
        q.push_back(r);
    }
    sort(q.begin(), q.end());
    //unique去重, erase删除重复元素
    q.erase(unique(q.begin(), q.end()), q.end());
    
    for (auto i : add) {
        int x = f(i.first);
        a[x] += i.second;
    }
    
    for (int i = 1; i <= q.size(); i++) s[i] = s[i - 1] + a[i];
    
    for (auto i : query) {
        cout << s[f(i.second)] - s[f(i.first) - 1] << endl;
    }
}